<?php
include 'secure/core.php';

if(isset($_POST['submit'])){
	if($users->confirmEmail(mysql_real_escape_string($_POST['email']),mysql_real_escape_string($_POST['activation']))){
		header( 'Location: login.php?msg=3' ) ;
	} else {
		header( 'Location: activate.php?msg=1' ) ;
        }
}
include 'header.php';
include 'left.php'; 
?>
		<div id="right">

			<div class="section">
			<?php if($_GET['msg'] == '1') { ?>
			 <div class="message red"><span><b>Error</b>: The activation code is invalid.</span></div>
			 <?php } ?>
							<div class="box">

					<div class="title">

						Activate Account

					</div>

					<div class="content">

						<form action="activate.php" method="post">

							<div class="row">

								<label>Email</label>

								<div class="right"><input type="text" value="" name="email" class="{validate:{required:true, messages:{required:'Please enter your email'}}}" /></div>

							</div>

							<div class="row">

								<label>Activate Code</label>
                                                                <?php if(isset($_GET['random'])) { ?>
                                                                <div class="right"><input type="activation" value="<?php echo $_GET['random']; ?>" name="activation" class="{validate:{required:true, messages:{required:'Please enter the activation code'}}}" /></div>
                                                                <?php } else { ?>
								<div class="right"><input type="activation" value="" name="activation" class="{validate:{required:true, messages:{required:'Please enter the activation code'}}}" /></div>
								<?php } ?>

							</div>

							<div class="row">

								<div class="right">

									<button type="submit" name="submit" class="green"><span>Submit</span></button>

								</div>

							</div>

						</form>

					</div>

				</div>

			</div>

		</div>

</div>
<?php include 'footer.php'; ?>